package com.hyjx.kjframe;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hyjx.kjframe.ui.AnnotateUtil;

/**
 * @author kymjs (https://github.com/kymjs)
 * @version 1.6
 * Created by zhengfuwang on 2015/5/11.
 */
public abstract class KJFragment extends Fragment implements View.OnClickListener{

    protected abstract View inflaterView(LayoutInflater inflater,
                                         ViewGroup container, Bundle bundle);

    /**
     * initialization widget, you should look like parentView.findviewbyid(id);
     * call method
     *
     * @param parentView
     */
    protected void initWidget(View parentView) {}

    /** widget click method */
    protected void widgetClick(View v) {}

    @Override
    public void onClick(View view) {
        widgetClick(view);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflaterView(inflater, container, savedInstanceState);
        AnnotateUtil.initBindView(this, view);
        initWidget(view);
        return view;
    }
}
